#include "StdAfx.h"
#include "TimerTomato.h"

TimerTomato::TimerTomato(void)
{
	if(this->time==nullptr) {
		this->time = gcnew Timer(10);
		this->time->Interval = 10;
		this->time->Elapsed += gcnew ElapsedEventHandler(TimerTomato::OnTimedEvent);
	}
	
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::pomodoro1,150000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::break1,18000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::pomodoro2,150000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::break2,18000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::pomodoro3,150000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::break3,18000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::pomodoro4,150000));
		this->tl.insert(cliext::map<long ,long >::make_value(TimerType::break4,90000));
	
}

TimerTomato::~TimerTomato(void)
{
	//delete this->tt;
	//delete
}

TimerTomato::TimerTomato(TimerTomato^ tom)
{
	this->time = tom->time;
	this->tl = tom->tl;
}

TimerTomato^ TimerTomato::instance(){
	
	if(tt==nullptr) tt = gcnew TimerTomato();

	return tt;

}
/**
bool TimerTomato::startAll()
{
}
bool TimerTomato::stopAll()
{
}
*/
bool TimerTomato::resetAll()
{
	this->time->Enabled=false;
	current = TimerType::pomodoro1;
	count = 0;
	return true;
}
bool TimerTomato::start(TimerType t)
{
	current = t;
	this->time->Enabled=true;
	return true;
}
bool TimerTomato::stop(TimerType t)
{
	current = t;
	this->time->Enabled=false;
	return true;
}
bool TimerTomato::reset(TimerType t)
{
	current = t;
	this->time->Enabled=false;
	count = 0;
	return true;
}
void TimerTomato::OnTimedEvent( Object^ source, ElapsedEventArgs^ e )
{
	count++;
	
    //setvalue(count);
	//up[0]->Text=mk.getFormatString(count);
	

}

bool TimerTomato::setvalue(long l){
	MakeString mk();

}

bool TimerTomato::setVectorLabel(cliext::vector<System::Windows::Forms::Label ^> up1){

	this->up = up1;
	return true;
}


bool TimerTomato::setVectorButton(cliext::vector<System::Windows::Forms::Button ^> bt1){

	this->bt = bt1;
	return true;
}